﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using YuriiOnufreiv;

namespace UnitTests
{
    [TestClass]
    public class UnitTests
    {
        [TestMethod]
        public void TestEmptyAdd()
        {
            String inputValue = "";
            int expectedResult = 0;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void TestOneParameterAdd()
        {
            String inputValue = "1";
            int expectedResult = 1;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void TestTwoParameterAdd()
        {
            String inputValue = "1,2";
            int expectedResult = 3;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);

        }

        [TestMethod]
        public void TestUnknownAmountOfParameterAdd()
        {
            String inputValue = "1,2,3,5";
            int expectedResult = 11;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void TestNewLineBetweenNumbersAdd()
        {
            String inputValue = "1\n2,3";
            int expectedResult = 6;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void TestDifferentDelimitersAdd()
        {
            String inputValue = "//[;]\n1;2";
            int expectedResult = 3;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException), "negatives not allowed")]
        public void TestExceptionWithNegativeParamAdd()
        {
            String inputValue = "-1";
            int result = StringManipulator.Add(inputValue);
        }

        [TestMethod]
        public void TestParamBigerThan1000Add()
        {
            String inputValue = "//[;]\n2;1001";
            int expectedResult = 2;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }

        [TestMethod]
        public void TestAnyLengthDelimitersAdd()
        {
            String inputValue = "//[***]\n1***2***3";
            int expectedResult = 6;
            int result = StringManipulator.Add(inputValue);
            Assert.AreEqual(expectedResult, result);
        }
    }
}
